home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2000 February / Macworld (2000-02).dmg / Games World / Hot demos! / Starbound II / AI agents / Gypsum 1.00 / Gypsum 1.00.rsrc / ss$t_131 < prev    next >
Text File  |  1999-10-30  |  1KB  |  51 lines

  1. situation planetary_bombardment_ship
  2. vars
  3.    p : planet;
  4.    s : structure;
  5.    a : integer;
  6.    weakest : structure; 
  7.    bomb : integer;
  8.    success : boolean;
  9.    focus : squad;
  10.  
  11. begin
  12.    // First see if the planet is an enemy race
  13.    if (Orbit_owner(This_planet()) <> Planet_race(This_planet())) then
  14.       begin
  15.          // Find a structure on the planet to bombard with the weakest armor
  16.          p := This_planet();
  17.          weakest := First_structure(p);
  18.          if (weakest <> nil) then
  19.             begin
  20.                s :=  Next_structure(p, weakest);
  21.                while (s <> nil) do
  22.                   begin
  23.                      if (Structure_armor(p, s) < Structure_armor(p, weakest)) then
  24.                         weakest := s;
  25.                      else if ((Structure_armor(p, s) = Structure_armor(p, weakest)) and
  26.                         (Random(4) = 0)) then
  27.                         weakest := s;
  28.                      s := Next_structure(p, s);
  29.                   end;
  30.                bomb := Structure_hex(p, weakest);
  31.                success := Bombard_planet(bomb);
  32.             end;
  33.       end;
  34.   // well, I guess we hunt enemy troops
  35.    focus := First_squad(-1);
  36.    success := false;
  37.    while ((focus <> nil) and (not success)) do
  38.       begin
  39.          if (Squad_race(focus) <>My_race()) then
  40.             begin
  41.                success := Bombard_planet(Squad_hex(focus));
  42.             end;
  43.          focus := Next_squad(focus, -1);
  44.       end;
  45. end;
  46.  
  47.  
  48.  
  49.  
  50.  
  51.